package model

import (
	"go-caipu/pkg/services/dto"
)

type SysMenu struct {
	MenuId     int64    `json:"menuId" gorm:"primaryKey;autoIncrement"`
	MenuName   string   `json:"menuName" gorm:"size:128;"`
	Title      string   `json:"title" gorm:"size:128;"`
	Icon       string   `json:"icon" gorm:"size:128;"`
	Path       string   `json:"path" gorm:"size:128;"`
	Paths      string   `json:"paths" gorm:"size:128;"`
	MenuType   int      `json:"menuType" gorm:"size:1;"`
	Status     int      `json:"status"`
	Action     string   `json:"action" gorm:"size:16;"`
	Permission string   `json:"permission" gorm:"size:255;"`
	Redirect   string   `json:"redirect" gorm:"size:100;"`
	ParentId   int64    `json:"parentId" gorm:"size:11;"`
	NoCache    bool     `json:"noCache" gorm:"size:8;"`
	Breadcrumb string   `json:"breadcrumb" gorm:"size:255;"`
	Component  string   `json:"component" gorm:"size:255;"`
	Sort       int      `json:"sort" gorm:"size:4;"`
	Visible    bool     `json:"visible" gorm:"size:1;"`
	IsFrame    bool     `json:"isFrame" gorm:"size:1;DEFAULT:0;"`
	SysApi     []SysApi `json:"sysApi" gorm:"many2many:sys_menu_api"`
	dto.ControlBy
	dto.ModelTime
	//创建人
	CreateUser SysUserBaseInfo `gorm:"foreignKey:CreateBy;references:UserId"`
	//更新人
	UpdateUser SysUserBaseInfo `gorm:"foreignKey:UpdateBy;references:UserId"`
}

func (SysMenu) TableName() string {
	return "sys_menu"
}

type SysRoleMenu struct {
	RoleId  int64     `json:"roleId"` // 角色编码
	SysMenu []SysMenu `json:"sysMenu" gorm:"many2many:sys_role_menu;foreignKey:RoleId;joinForeignKey:role_id;references:MenuId;joinReferences:menu_id;"`
}

func (SysRoleMenu) TableName() string {
	return "sys_role_menu"
}

type SysMenuAPI struct {
}

func (SysMenuAPI) TableName() string {
	return "sys_menu_api"
}
